package com.xy.kit;

import lombok.Data;


@Data
public class ResultData {
    private Integer code;
    private String msg;
    private Object data;

    private ResultData() {
    }

    public static ResultData success() {
        ResultData data = new ResultData();
        data.setCode(200);
        return data;
    }

    public static ResultData success(Object dataObj) {
        ResultData data = new ResultData();
        data.setCode(200);
        data.setData(dataObj);
        return data;
    }

    public static ResultData fail(String message) {
        ResultData data = new ResultData();
        data.setCode(500);
        data.setMsg(message);
        return data;
    }

    public static ResultData fail(String message, Object dataObj) {
        ResultData data = new ResultData();
        data.setCode(500);
        data.setMsg(message);
        data.setData(dataObj);
        return data;
    }

    public static ResultData fail(Integer code, String message, Object dataObj) {
        ResultData data = new ResultData();
        data.setCode(code);
        data.setMsg(message);
        data.setData(dataObj);
        return data;
    }

    public Integer getCode() {
        return code;
    }


    public String getMsg() {
        return msg;
    }


    public Object getData() {
        return data;
    }


    public boolean getSuccess() {
        if (Integer.valueOf(200).equals(code)) {
            return true;
        }
        return false;
    }
}

